package com.verisette.ncos.common;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;

public class ProjectConstant {
	public static String BASE_APP_FOLDER = null;
	public static String USER_FOLDER_FORMAT = null;
	public static String APP_FONTS_FOLDER = null;
	public static String APP_IMAGES_FOLDER = null;
	
	public static String APP_MMB_IMAGES_FOLDER=null;
	public static String APP_ORDER_PDF_FOLDER = null;
	public static String APP_ORDER_PDF_PREVIEW_FOLDER = null;
	
	public static String APP_ORDER_PO_FOLDER = null;
	
	//TEMP
	public static String APP_TEMP_IMG_FOLDER=null;
	public static String APP_TEMP_PDF_FOLDER=null;
	public static String APP_TEMP_PDF_PREVIEW_FOLDER=null;
	
	//PDF
	public static String FONT_PSLPRO_NORMAL="PSL Irene Pro Regular\\PSL005pro.ttf";
	public static String FONT_NAME_PSLPRO_NORMAL = "psl_irene";
	public static String FONT_PSLPRO_BOLD="PSL Irene Pro Bold\\PSL006pro.ttf";
	public static String FONT_NAME_PSLPRO_BOLD = "psl_irene_bold";
    public static String FONT_PSLPRO_ITALIC = "PSL Irene Pro Italic\\PSL007pro.ttf";
    public static String FONT_NAME_PSLPRO_ITALIC = "psl_irene_italic";

    //Kittithada
	public static String FONT_PSLxKittithada_NORMAL="PSLxKittithada.ttf";
	public static String FONT_NAME_PSLxKittithada_NORMAL = "PSLxKittithada";
	public static String FONT_PSLxKittithada_BOLD="PSLxKittithada Bold.ttf";
	public static String FONT_NAME_PSLxKittithada_BOLD = "PSLxKittithadaBold";
    public static String FONT_PSLxKittithada_ITALIC = "PSLxKittithada Italic.ttf";
    public static String FONT_NAME_PSLxKittithada_ITALIC = "PSLxKittithadaItalic";
    public static String FONT_PSLxKittithada_BOLD_ITALIC = "PSLxKittithada BoldItalic.ttf";
    public static String FONT_NAME_PSLxKittithada_BOLD_ITALIC = "PSLxKittithadaBoldItalic";

    //Kittithada Text
	public static String FONT_PSLxText_NORMAL="PSLxText.ttf";
	public static String FONT_NAME_PSLxText_NORMAL = "PSLxText";
	public static String FONT_PSLxText_BOLD="PSLxText Bold.ttf";
	public static String FONT_NAME_PSLxText_BOLD = "PSLxTextBold";
    public static String FONT_PSLxText_ITALIC = "PSLxText Italic.ttf";
    public static String FONT_NAME_PSLxText_ITALIC = "PSLxTextItalic";
    public static String FONT_PSLxText_BOLD_ITALIC = "PSLxText BoldItalic.ttf";
    public static String FONT_NAME_PSLxText_BOLD_ITALIC = "PSLxTextBoldItalic";
    
//    public static SimpleDateFormat FILE_PDF_FORMAT = new SimpleDateFormat("'NameCard_Y'yyyy'M'MM'D'dd''HH'M'mm'S'ss's'SSS'.pdf'");

    public static Locale defaultLocale = new Locale("th","TH");
    
    public static SimpleDateFormat FILE_PDF_FORMAT = new SimpleDateFormat("'%s%s_THP_'ddMMyyyy'_'HHmmss'_'SSS'.pdf'", defaultLocale);
    
//    public static SimpleDateFormat FILE_IMG_FORMAT = new SimpleDateFormat("'%s_Y'yyyy'M'MM'D'dd'H'HH'm'mm's'ss'_'SSS");
    public static SimpleDateFormat FILE_IMG_FORMAT = new SimpleDateFormat("'%s%s_THP_'ddMMyyyy'_'HHmmss'_'SSS", defaultLocale);
    
    public static float CARD_WIDTH = ((9.2f/2.54f)*72f);
    public static float CARD_HEIGHT= ((5.7f/2.54f)*72f);
    
    
    public static String RPT_DATE_FORMAT = "dd MMMM yyyy";
    
    //#USER_LEVEL
    public static final String ADMINISTRATOR = "Administrator";//For printer too
    
    public static final String NORMAL_USER_HQ =  "HQ";
    public static final String NORMAL_USER_REGION = "Region";
    public static final String NORMAL_USER_BRANCH = "Branch";
    
    public static final String APPROVAL_LV1 = "Approval lv1";
    public static final String APPROVAL_LV2 = "Approval lv2";
    
    public static List<String> cardOrderAmountList = null;
    
	
	public static String REPORT_RESULT_PATH; //TODO: Check src/ProjectConstant.properties before deploy
	public static String EXPORT_RESULT_PATH; //TODO: Check src/ProjectConstant.properties before deploy
	static {
		try{
			ResourceBundle resource = ResourceBundle.getBundle("ProjectConstant");
			String environment = resource.getString("ENVIRONMENT");
			REPORT_RESULT_PATH=String.format("D:\\%s\\ExportExcelFile\\", environment);
			EXPORT_RESULT_PATH=String.format("D:\\%s\\ExportTextFile\\", environment);
			BASE_APP_FOLDER=resource.getString("BASE_APP_FOLDER");//D:\..\NCOS\APP
			APP_FONTS_FOLDER=String.format(BASE_APP_FOLDER+"\\%s", resource.getString("APP_FONTS_FOLDER"));
			APP_ORDER_PDF_FOLDER=String.format(BASE_APP_FOLDER+"\\%s", resource.getString("APP_ORDER_PDF_FOLDER"));
			APP_ORDER_PO_FOLDER=String.format(BASE_APP_FOLDER+"\\%s", resource.getString("APP_ORDER_PO_FOLDER"));
			USER_FOLDER_FORMAT=resource.getString("USER_FOLDER_FORMAT");//USER_%s
			APP_IMAGES_FOLDER=String.format(BASE_APP_FOLDER+"\\%s", resource.getString("APP_IMAGES_FOLDER"));
			FILE_PDF_FORMAT = new SimpleDateFormat(resource.getString("FILE_PDF_FORMAT"));
			FILE_IMG_FORMAT = new SimpleDateFormat(resource.getString("FILE_IMG_FORMAT"));
			
			APP_TEMP_IMG_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_TEMP_IMG_FOLDER");
			APP_TEMP_PDF_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_TEMP_PDF_FOLDER");
			APP_TEMP_PDF_PREVIEW_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_TEMP_PDF_PREVIEW_FOLDER");
			
			APP_MMB_IMAGES_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_MMB_IMAGES_FOLDER");
			APP_ORDER_PDF_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_ORDER_PDF_FOLDER");
			APP_ORDER_PDF_PREVIEW_FOLDER=BASE_APP_FOLDER+"\\"+resource.getString("APP_ORDER_PDF_PREVIEW_FOLDER");
			
			FONT_PSLPRO_NORMAL = APP_FONTS_FOLDER + "\\" + FONT_PSLPRO_NORMAL;
			FONT_PSLPRO_BOLD = APP_FONTS_FOLDER + "\\" + FONT_PSLPRO_BOLD;
			FONT_PSLPRO_ITALIC = APP_FONTS_FOLDER + "\\" + FONT_PSLPRO_ITALIC;

			FONT_PSLxKittithada_NORMAL = APP_FONTS_FOLDER + "\\" + FONT_PSLxKittithada_NORMAL;
			FONT_PSLxKittithada_BOLD = APP_FONTS_FOLDER + "\\" + FONT_PSLxKittithada_BOLD;
			FONT_PSLxKittithada_ITALIC = APP_FONTS_FOLDER + "\\" + FONT_PSLxKittithada_ITALIC;
			FONT_NAME_PSLxKittithada_BOLD_ITALIC = APP_FONTS_FOLDER + "\\" + FONT_NAME_PSLxKittithada_BOLD_ITALIC;

			FONT_PSLxText_NORMAL = APP_FONTS_FOLDER + "\\" + FONT_PSLxText_NORMAL;
			FONT_PSLxText_BOLD = APP_FONTS_FOLDER + "\\" + FONT_PSLxText_BOLD;
			FONT_PSLxText_ITALIC = APP_FONTS_FOLDER + "\\" + FONT_PSLxText_ITALIC;
			FONT_NAME_PSLxText_BOLD_ITALIC = APP_FONTS_FOLDER + "\\" + FONT_NAME_PSLxText_BOLD_ITALIC;
			
			String cardOrderAmountListStr = resource.getString("CARD_ORDER_AMOUNT_LIST");
			if(cardOrderAmountListStr!=null && cardOrderAmountListStr.length()>0){
				cardOrderAmountList=new ArrayList<String>();
				String[] ss = cardOrderAmountListStr.split(",");
				for(String cardOrderAmt : ss) {
					cardOrderAmountList.add(cardOrderAmt);
				}
			}
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
	public static final int    ROW_PER_PAGE			= 10;
	
	public static final String ACTIVE_FLAG			= "A";
	public static final String INACTIVE_FLAG 		= "I";
	
	public static final String Y_FLAG 				= "Y";
	public static final String N_FLAG 				= "N";
	
	public static final String YES_FLAG 			= "Yes";
	public static final String NO_FLAG 				= "No";
	
	public static final String RJR_TYPE_REJECT		= "R";
	public static final String RJR_TYPE_WAIT		= "W";
	public static final String RJR_TYPE_PENDING		= "P";
	
	public static final String STATUS_NEW 					= "10";
	public static final String STATUS_ASSIGN 				= "20";
	public static final String STATUS_REASSIGN 				= "21";
	public static final String STATUS_EDIT 					= "30";
	public static final String STATUS_EDIT_BY_APPROVER		= "31";
	public static final String STATUS_WAIT_FOR_APPROVE 		= "40";
	public static final String STATUS_APPROVE 				= "50";
	public static final String STATUS_PENDING 				= "60";
	public static final String STATUS_PENDING_WITH_COMMENT 	= "70";
	public static final String STATUS_RECALL 				= "90";
	public static final String STATUS_RECALL_BY_APPROVER	= "91";
	
	
	public static final String EXPIRE_DAY		 			= "90";
	
	public static final String SCREEN_MODE_EDITOR 			= "editor";
	public static final String SCREEN_MODE_APPROVER 		= "approver";
	
	public static final String MESSAGE_CODE_ACC0001 = "ACC0001"; 	
	public static final String MESSAGE_CODE_ACC0002 = "ACC0002"; 
	public static final String MESSAGE_CODE_ACC0003 = "ACC0003"; 
	public static final String MESSAGE_CODE_ACC0004 = "ACC0004"; 	
	public static final String MESSAGE_CODE_ACC0005 = "ACC0005"; 
	public static final String MESSAGE_CODE_ACC0006 = "ACC0006"; 
	public static final String MESSAGE_CODE_ACC0007 = "ACC0007"; 
	public static final String MESSAGE_CODE_ACC0008 = "ACC0008"; 
	public static final String MESSAGE_CODE_ACC0009 = "ACC0009"; 
	public static final String MESSAGE_CODE_ACC0010 = "ACC0010"; 
	public static final String MESSAGE_CODE_ACC0011 = "ACC0011"; 	
	
	public static final String MESSAGE_CODE_TAS0501 = "TAS0501";
	public static final String MESSAGE_CODE_TAS0502 = "TAS0502";
	
	public static final String MESSAGE_CODE_MCP0001 = "MCP0001";
	public static final String MESSAGE_CODE_MCP0002 = "MCP0002";
	
	public static final String MESSAGE_NO_RECORD_FOUND = "No record found."; 
	
	// UserProfileManagement
	public static final String MESSAGE_CODE_USP0001 = "USP0001";
	public static final String MESSAGE_CODE_USP0002 = "USP0002"; 
	public static final String MESSAGE_CODE_USP0003 = "USP0003"; 
	
	public static final String MESSAGE_CODE_RMN0001 = "RMN0001";
	public static final String MESSAGE_CODE_TAS0503 = "TAS0503";
	
	public static final String USER_PROFILE = "userProfile";
	public static final String USER_PROFILE_ASSIGNED_ROLE = "userProfileAssignedRole";
	public static final String USER_PROFILE_ROLE_LIST = "roleList";
	public static final String USER_PROFILE_ID = "uspId";
	public static final String USER_PROFILE_USERNAME = "uspUserName";
	public static final String USER_PROFILE_STATUS_ACTIVE = "A";
	public static final String USER_PROFILE_STATUS_INACTIVE = "I";
	public static final String USER_PROFILE_LOG_PAGING_BEAN = "logPagingBean";
	public static final String USER_PROFILE_LOG_REQUEST_PAGE = "logRequestPage";
	public static final String USER_PROFILE_LOG_ROWS_PER_PAGE = "logRowsPerPage";
	public static final String USER_PROFILE_OLD_PASSWORD = "oldPassword";
	public static final String USER_PROFILE_NEW_PASSWORD = "newPassword";
	public static final String USER_PROFILE_IP_ADDRESS = "ipAddress";
	
	// AuditLog
	public static final String AUDIT_LOG_SEARCH = "auditLogSearch";
	public static final String AUDIT_LOG_CLASS_MASTER = "MASTER";
	
	// UserGroupManagement
	public static final String MESSAGE_CODE_USG0001 = "USG0001";
	
	//Date Time Format
	public static final String DATE_FORMAT = "dd/MM/yyyy";
	public static final String DATE_TIME_FORMAT = "dd/MM/yyyy HH:mm:ss";
	
	//Login
	public static final String DEFAULT_PASSWORD = "Password123";
	public static final String MAXIMUM_WRONG_LOGIN_COUNTER = "20";
	public static final String DEFAULT_WRONG_LOGIN_COUNTER = "0";
	public static final String ACCESS_LOG_INPUT_INCORRECT_PASSWORD = "Input incorrect password";
	public static final String ACCESS_LOG_ACCOUNT_LOCKED = "Account is locked";
	public static final String ACCESS_LOG_CHANGE_PWD_COMPLETE = "Change password complete";
	public static final String ACCESS_LOG_INACTIVE_USER_TRY_TO_LOGIN = "Inactive user try to login";
	public static final String ACCESS_LOG_LOGIN_COMPLETE = "Login complete";
	public static final String ACCESS_LOG_MESSAGE = "logMessage";
	public static final String ACCESS_LOG_USER_LOCK = "User Lock try to login";
	
	//Change Password							  
	//public static final String PASSWORD_PATTERN = "^(?=.{8,})(?=.*[a-zA-Z])(?=.*[\\d])(?=.*[^\\w\\d\\s]).*$";
	public static final String PASSWORD_PATTERN = "^.{8,16}$";
	public static final String CHANGE_PASSWORD_OLD_PASSWORD = "oldPassword";
	public static final String CHANGE_PASSWORD_NEW_PASSWORD = "newPassword";
	public static final String CHANGE_PASSWORD_CONFIRM_PASSWORD = "confirmPassword";
	public static final String CHANGE_PASSWORD_OBJ_ID = "010400";
	public static final String CHANGE_PASSWORD_FORCE_TO_CHANE_PWD_FLAG = "Y";
	public static final int	   CHANGE_PWD_DUPLICATE = 5;
	public static final String CASE_DUPLICATE_ID 	= "1";
	public static final String CASE_MATCHING_DATA 	= "2";
	
	//IdType
	public static final String ID_TYPE_CI 	= "CI";
	public static final String ID_TYPE_OP 	= "OP";
	public static final String ID_TYPE_PP 	= "PP";
	public static final String ID_TYPE_AI 	= "AI";
	public static final String ID_TYPE_OI 	= "OI";
	public static final String ID_TYPE_JR 	= "JR";
	public static final String ID_TYPE_GO 	= "GO";
	public static final String ID_TYPE_SW 	= "SW";
	public static final String ID_TYPE_FI 	= "FI";
	public static final String ID_TYPE_OC 	= "OC";
	public static final String ID_TYPE_OJ 	= "OJ";
	public static final String ID_TYPE_OG 	= "OG";
	
//	public static final String REPORT_RESULT_PATH	= "D:\\PROD\\ExportExcelFile\\"; //TODO
//	public static final String EXPORT_RESULT_PATH	= "D:\\PROD\\ExportTextFile\\"; //TODO
	
	public static final String REPORT_STATUS_COMPLETE	= "COMPLETE";
	public static final String REPORT_STATUS_PENDING	= "PENDING";
	public static final String REPORT_STATUS_PROCESS	= "PROCESS";
	public static final String REPORT_STATUS_FAIL		= "FAIL";
	public static final String REPORT_STATUS_DATA_NOT_FOUND		= "Data not found";
	
	public static final String REPORT_DATA_EDITOR_PERFORMANCE			= "Data Editor Performance Report";
	public static final String REPORT_DATA_APPROVE_PERFORMANCE			= "Data Approve Performance Report";
	public static final String REPORT_APPROVAL_RESULT_COMPARISON_BETWEEN_DATA_EDITOR_AND_DATA_APPROVER	= "Approval Result Comparison Between Data Editor And Data Approver Report";
	public static final String REPORT_MATCHING_SUMMARY_PERFORMANCE		= "Matching Summary Performance Report";
	public static final String REPORT_DATA_REQUEST_SUMMARY				= "Data Request Summary Report";
	public static final String REPORT_DUPLICATEID_PERFORMANCE_SUMMARY	= "DuplicateId Performance Summary Report";
	public static final String REPORT_UNHANDLED_ADDERSS_SUMMARY			= "Unhandled Address Summary Report";
	public static final String REPORT_REJECT_REASON_SUMMARY				= "Reject Reason Summary Report";
	public static final String REPORT_RESIDUAL_SUMMARY					= "Residual Summary Report";
	public static final String REPORT_WAITFOR_INFORMATION_REASON_SUMMARY	= "Wait for Information Reason Summary Report";
	public static final String REPORT_PENDING_REASON_SUMMARY			= "Pending Reason Summary Report";
	
	public static final String EXPORT_TO_BRANCH		= "Export to branch";
	public static final String EXPORT_TO_CDMP		= "Export to CDMP";
//	public static final String EXPORT_ID_NO			= "Export ID No.";
	public static final String EXPORT_ID_NO			= "Export to DOPA";
	public static final String EXPORT_ENCODE_TIS620	= "TIS-620";
	
	public static final int STATUS_WAIT_APPROVE = 0;
	public static final int STATUS_APPROVE_N = -1;
	public static final int STATUS_APPROVE_Y = 1;
	public static final int STATUS_APPROVE02_N = -2;
	public static final int STATUS_APPROVE02_Y = 2;
	// 06/05/2013 - skip approval process
	//public static final int STATUS_WAIT_PRINT = STATUS_APPROVE02_Y;
	public static final int STATUS_WAIT_PRINT=STATUS_WAIT_APPROVE;
	public static final int STATUS_PRINT = 3;
	public static final int STATUS_PRINT_CANCEL = -3;
	
	public static final String AUTO_EXPORT_START_TIME	= "21:00:00";
		
	public static final String PARAM_USERNAME = "P_USERNAME";
	
	public static final String PARAM_MTPSHORTNAME = "P_MTPSHORTNAME";
	public static final String PARAM_PRINTTYPE = "P_PRINTTYPE";
	public static final String PARAM_FILEEXTENSION = "P_FILEEXTENSION";
	
	public static final String SESSION_MENU_PAGE = "SESSION_MENU_PAGE";

	public static final String SESSION_SEARCH_ORDER_STATUS = "SESSION_SEARCH_ORDER_STATUS";

	public static final String MENU_PAGE_CREATE_CARD = "MENU_PAGE_CREATE_CARD";
	public static final String MENU_PAGE_APPROVED01 = "MENU_PAGE_APPROVED01";
	public static final String MENU_PAGE_APPROVED02 = "MENU_PAGE_APPROVED02";
	public static final String MENU_PAGE_PRINTER = "MENU_PAGE_PRINTER";
	public static final String MENU_PAGE_CONTACT = "MENU_PAGE_CONTACT";
	
	public static final Integer DEFAULT_PRINTER_USP_ID = 6;
	public static final float DEFAULT_30 = 30.00f;

	public static String DEFAULT_DISP_30 ;
	
	static {
		NumberFormat nfFloat = new DecimalFormat("#,##0.00");
		try{
			DEFAULT_DISP_30 = nfFloat.format( DEFAULT_30 );
		}catch(NumberFormatException nfex){
			nfex.printStackTrace();
		}
	}
}
